// Copyright (c) 2009 Hypirinha contributers
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.codegen;

import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.PrintStream;
import java.io.ByteArrayOutputStream;

public class InnerInterfaceTest {

    @Test
    public void shouldRenderAsASingleLineWithIndent() {
        assertEquals("\n    interface Attribute {}\n", print(new InnerInterface("Attribute")));
    }

    @Test
    public void shouldIncludeBaseInterface() {
        InnerInterface innerInterface = new InnerInterface("Attribute");
        innerInterface.addBaseInterface("AnyAttribute");
        assertEquals("\n    interface Attribute extends AnyAttribute {}\n", print(innerInterface));
    }

    private String print(InnerInterface generatedInterface) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        generatedInterface.printTo(new PrintStream(outputStream));
        return new String(outputStream.toByteArray());
    }
}